import os,sys
dir="."
extlst=[".jpg",".png"]
ct=1
if len(sys.argv) > 1:dir=sys.argv[1]
os.chdir(dir)

def flat_folder(dir):
	global ct
	l=os.listdir(dir)
	for s in l:
		if os.path.isdir(dir+"\\"+s):
			flat_folder(dir+"\\"+s)
		else:
			ext=os.path.splitext(s)[1]
			if not ext in extlst:continue
			os.rename(dir+"\\"+s,str(ct)+ext)
			ct+=1

flat_folder(".")
